package ar.com.unlp.fi.lrs.domain;

import java.util.List;
import java.util.Vector;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import com.fasterxml.jackson.annotation.JsonTypeName;

/**
 * El actor puede representar a un agente o a un grupo.
 * 
 * https://github.com/adlnet/xAPI-Spec/blob/master/xAPI.md#actor
 * 
 * 
 */
@Entity
@Table(name="Actor")
@DiscriminatorValue("GROUP")

@JsonTypeName("GROUP")

public class Group extends Actor{

	private List<Agent> members = new Vector<Agent>();

	@ManyToMany
	@JoinTable(name = "GROUP_MEMBER", joinColumns = @JoinColumn(name = "GROUP_ID"), inverseJoinColumns = @JoinColumn(name = "MEMBER_ID"))
	@LazyCollection(LazyCollectionOption.FALSE) 
	public List<Agent> getMembers() {
		return members;
	}

	public void setMembers(List<Agent> members) {
		this.members = members;
	}



	@Override
	@Transient
	public String getObjectStatemetnType() {
		return StatementObject.GROUP;
	}
}
